package com.cg;

/**
 * @author cheyinbo
 * @description TODO
 * @date 2021/8/18 11:40
 */
public class StaticProxy {
    public static void main(String[] args) {
        TeacherDao teacherDao = new TeacherDaoImpl();
        TeacherDaoProxy teacherDaoProxy = new TeacherDaoProxy(teacherDao);
        teacherDaoProxy.teach("詹老师");

    }
}


interface TeacherDao {

    void teach(String teacherName);

}

class TeacherDaoImpl implements TeacherDao {

    @Override
    public void teach(String teacherName) {
        System.out.println(teacherName + "正在教课...");
    }
}

class TeacherDaoProxy implements TeacherDao {

    private TeacherDao teacherDao;

    public TeacherDaoProxy(TeacherDao teacherDao) {
        this.teacherDao = teacherDao;
    }

    @Override
    public void teach(String teacherName) {
        System.out.println("代理开始");
        teacherDao.teach(teacherName);
        System.out.println("代理结束");
    }
}
